//
//  WKProgressView.m
//  WKMaybell
//
//  Created by 何文虎 on 2019/1/3.
//  Copyright © 2019 何文虎. All rights reserved.
//

#import "WKProgressView.h"

@interface WKProgressView()
@property(nonatomic,strong)UIView *cacheView;

@property(nonatomic,strong)UIView *playProgressView;
@end

@implementation WKProgressView

-(instancetype)initWithFrame:(CGRect)frame{
    self =  [super initWithFrame:frame];
    
    if (self) {
        self.backgroundColor = UIColorFromHex(0xF54050);
        
        [self addSubview:self.cacheView];
        
        [self addSubview:self.playProgressView];
    }
    return self;
}
-(void)setPlayValue:(CGFloat)playValue{
    _playValue = playValue;
    
    self.playProgressView.lx_width = playValue * self.lx_width;
    
}

-(void)setCacheValue:(CGFloat)cacheValue{
    _cacheValue = cacheValue;
    self.cacheView.lx_width = cacheValue * self.lx_width;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    
    self.playProgressView.lx_width = self.playValue * self.lx_width;
    
    self.cacheView.lx_width = self.cacheValue * self.lx_width;
    
}
-(UIView *)cacheView{
    if (!_cacheView) {
        _cacheView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, self.lx_height)];
        
        _cacheView.backgroundColor = UIColorFromHex(0xF4F4F4);
    }
    return _cacheView;
}
-(UIView *)playProgressView{
    
    if (!_playProgressView) {
        _playProgressView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, self.lx_height)];
        
        _playProgressView.backgroundColor =[UIColor whiteColor];
    }
    return _playProgressView;
}

@end
